package cn.codinglives.demo.shopping.product.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
public class ProductController {
    private final static Logger logger = LoggerFactory.getLogger(ProductController.class);

    @GetMapping("/product/stock")
    @ResponseBody
    public List<ProductVO> stocks(){
        List<ProductVO> productVOList = new ArrayList<>();
        productVOList.add(new ProductVO("1001", "iphone", 5000, 100));
        productVOList.add(new ProductVO("1002", "mate40", 8000, 200));
        return productVOList;
    }


    @GetMapping("/product/deductStock")
    public String deductStock(@RequestParam String productId) {
        logger.info("deduct stock:{}", productId);
        return "ok";
    }
}
